<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/include/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>

<d:script id="jquery,jquery-cookie,om-ui" />
<d:css id="om-ui" />
<d:css path="static/style/common.css"/>
<script type="text/javascript">
$(document).ready(function() {
	//dialogUser弹出的子窗口保存数据
	window.saveData = function(){
		var dialogWindow = $("iframe",$("#dialogRole"))[0];
		$(dialogWindow.contentDocument).find("#formRole").omAjaxSubmit({  
			dataType:"json",
			url:"${ctx}/system/role/ajaxSave",
			success:function(data){
				if(data.success){
					$.omMessageTip.show({
						timeout:3000,
						title:"提示",
						content:"操作成功！"
					});
					dialogRole.close();
					gridRole.reload(1);
				} else {
					$.omMessageTip.show({
						timeout:3000,
						title:"失败",
						content:data.msg
					});
				}
			}
		});
		
	}
	function openDialogRole(title,id){
		dialogRole.option("title",title);
		dialogRole.option("path","${ctx}/system/role/edit?id="+(id?id:""));
		dialogRole.open();
	}
	var initConfig={};
	initConfig.gridRole={
		colModel : [ {header : '角色名称', name : 'name', width : 100, align : 'center'}, 
                     {header : '角色描述', name : 'remark', width : "autoExpand"}, 
                   ]
	}
	initConfig.buttonAdd={
		click:function(){
			openDialogRole("添加角色");
		}
	}
	initConfig.buttonSearch={
			click:function(){
				gridRole.option("extraData",{name:$("#param_name").val()});
				gridRole.setData("${ctx }/system/user/gridData");
			}
		}
	initConfig.buttonEdit={
		onClick:function(){
			var rowData = gridRole.getSelections(true);
    	    if(rowData.length<1){
    		    alert("请先选择要编辑的记录.");
    		    return false;
    	    }
    	    openDialogRole("编辑角色",rowData[0].id);
		}
	}
	//对页面中的组件进行初始化
	initUI(initConfig);
});
</script>
</head>
<body>

	<div id="dialogRole" class="ui-dialog" autoOpen="false" cacheable="false" modal="true" width="480" height="400">
		<span class="ui-dialog-button" text=" 保存 " click='function(){saveData();}'></span>
		<span class="ui-dialog-button" text=" 取消" click='function(){dialogRole.close()}'></span>
	</div>
	<div class="ui-grid" id="gridRole" method="POST" dataSource="${ctx }/system/role/gridData" height="fit">
		<div class="ui-grid-panel">
			<!-- 数据检索 -->
			<div class="ui-panel" label="检索条件" collapsible="true">
				<table>
					<tr>
						<td width="100px" colspan="1">角色名:</td>
						<td colspan="1"><input type="text" id="param_name" name="name"> </td>
						<td colspan="1"><button id="buttonSearch" class="ui-button" label=" 查询 "></button> </td>
					</tr>
				</table>
			</div>
			<div id="buttonbarRole" class="ui-buttonbar">
				<a id="buttonAdd" class="ui-button" label="添加角色" left-icon="${ctx }/static/icons/edit_add.png"></a>
				<a id="buttonEdit" class="ui-button" label="编辑角色" left-icon="${ctx }/static/icons/edit_add.png"></a>
			</div>
		</div>
	</div>
</body>
</html>